$(document).ready(function() {
	
	$("#header_menu").children().first().addClass('current');
	
	$("#header_menu li").click(function(){
		$("#header_menu").children().each(function() {
			$(this).removeClass('current');
		});
		$(this).addClass('current');		
	});
	
	var language = $("div.language").attr('id');
	$("ul.list-language").children().each(function() {
		var id = $(this).attr('id');
		if (language == id){
			$(this).addClass('current');
		}
	});
	
	$("a#profile").click(function(){
		$("#header_menu").children().each(function() {
			$(this).removeClass('current');
		});
	});
		
	$("ul.list-language li a").click(function(){
		var lan = $(this).attr('class');
		$.ajax({
			type : "POST",
			url : "change-langauge.php",
			data :{'lan' : lan},
			dataType : "json",
			success : function(msg) {
				if( msg.status =="ok" ){
					top.location.reload();
				}
			},
			error : function(xhr, ajaxOptions, thrownError) {
				alert("Pegasus: có lỗi trong quá trình gửi dữ liệu! ");
			}
		});
	})
});